package com.codeoss.framework.service.impl;

import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.ureport.export.html.HtmlReport;
import com.codeoss.framework.response.DocReportPageResponse;
import com.codeoss.framework.service.IDocReportPageService;
import com.codeoss.framework.ureport2.UReport2Util;

@Service
public class DocReportPageService implements IDocReportPageService {
	@Autowired
	private UReport2Util uReport2Util;
	@Override
	public DocReportPageResponse init(String reportCode, Long recordId) {
		// TODO Auto-generated method stub
		DocReportPageResponse docReportPageResponse=new DocReportPageResponse();
		Map<String,Object> paraMap=new HashMap<String,Object>();
		paraMap.put("id", recordId);
		HtmlReport htmlReport=uReport2Util.exportHtmlReport(reportCode, paraMap);
		docReportPageResponse.setStyle(htmlReport.getStyle());
		docReportPageResponse.setContent(htmlReport.getContent());
		return docReportPageResponse;
	}
	
	@Override
	public void dataExport(String reportCode, Long recordId, String format, OutputStream os) {
		// TODO Auto-generated method stub
		Map<String,Object> paraMap=new HashMap<String,Object>();
		paraMap.put("id", recordId);
		uReport2Util.dataExport(reportCode, paraMap, format, os);
	}

}
